// import TodoList from '@/components/TodoList'  // TodoList案例

import { Suspense,lazy,useEffect } from 'react'
import { Routes, Route ,useNavigate } from 'react-router-dom'


const Login = lazy(() => import('@/pages/Login/index.jsx'))
const ForgetPwd = lazy(() => import('@/pages/ForgetPwd/index'))
const Register = lazy(() => import('@/pages/Register/index.jsx'))
const NotFound = lazy(() => import('@/pages/NotFound/index.jsx'))

// 使用重定向
function Redirect({ to }) {
    let navigate = useNavigate();
    useEffect(() => {
      navigate(to);
    });
    return null;
}

 export default function App () {
    return (
        <Suspense fallback={<>loading...</>}>
                <Routes>
                    <Route path="/" element={<Redirect to="/login" />} />
                    <Route path='/login' exact= {true} element= {<Login/>} />
                    <Route path='/forget' exact= {true} element= {<ForgetPwd />}></Route>
                    <Route path='/register' exact= {true} element= {<Register/>} />
                    <Route path='*' element= {<NotFound/>} />
                </Routes>
        </Suspense>
    )
 }